Socket
Socket
Sign inDemoInstall

yarn-or-npm

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yarn-or-npm

Use Yarn or npm to execute a command


Version published
Weekly downloads
168K
increased by8.04%
Maintainers
1
Weekly downloads
 
Created

What is yarn-or-npm?

The yarn-or-npm package is a utility that helps developers determine whether to use Yarn or npm for running scripts and installing dependencies. It provides a simple API to detect the package manager being used in a project and execute commands accordingly.

What are yarn-or-npm's main functionalities?

Detecting the package manager

This feature allows you to detect whether Yarn or npm is being used in the current project. The code sample demonstrates how to require the yarn-or-npm package, call it to determine the package manager, and log the result.

const yarnOrNpm = require('yarn-or-npm');
const packageManager = yarnOrNpm();
console.log(`Using ${packageManager}`);

Running commands with the detected package manager

This feature allows you to run commands using the detected package manager. The code sample shows how to use the execSync function from the child_process module to run the install command with the detected package manager.

const yarnOrNpm = require('yarn-or-npm');
const { execSync } = require('child_process');
const packageManager = yarnOrNpm();
execSync(`${packageManager} install`);

Other packages similar to yarn-or-npm

Keywords

FAQs

Package last updated on 21 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc